package com.example.rabbitmq.service.impl;

import com.example.common.service.TestService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/**
 * @author <a href="nav1cat@outlook.com">nav1c</a>
 * @apiNote
 * @date 2023-12-15 16:03:09
 * @project study-cloud
 * @kit IntelliJ IDEA
 */
@Service
public class MessageMqServiceImpl implements TestService {
    private static final Logger log = LoggerFactory.getLogger(MessageMqServiceImpl.class);

    private final AmqpTemplate amqpTemplate;

    @Value("${spring.rabbitmq.template.exchange}")
    private String exchange;

    @Autowired
    public MessageMqServiceImpl(AmqpTemplate amqpTemplate) {
        this.amqpTemplate = amqpTemplate;
    }

    @Override
    public Object doTest(Object param) {
        amqpTemplate.convertAndSend(exchange, param);
        return null;
    }
}
